<?php

declare (strict_types=1);
namespace App\Model;

use Hyperf\Database\Model\Relations\HasOne;
use Hyperf\DbConnection\Model\Model;
/**
 * @property int $id 主键ID
 * @property int $device_id 设备表id
 * @property int $user_id 客服ID
 * @property int $project_id 项目ID
 * @property string $login_time 登录时间
 * @property string $logout_time 登出时间
 * @property \Carbon\Carbon $created_at 创建时间
 * @property \Carbon\Carbon $updated_at 更新时间
 * @property int $status 状态 (1正常 2禁用)
 * @property string $marketUserId 运营者编号
 * @property string $title 运营者名称
 */
class WeworkOperation extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'wework_operation';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['id', 'device_id', 'user_id', 'project_id', 'login_time', 'logout_time', 'created_at', 'updated_at', 'status', 'marketUserId', 'title'];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'integer', 'device_id' => 'integer', 'user_id' => 'integer', 'project_id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'status' => 'integer'];
    /**
     * 设备账号表和设备 一对一
     * @return HasOne
     */
    public function UserDevice() : HasOne
    {
        return $this->HasOne(UserDevice::class, 'id', 'device_id');
    }
    /**
     * 运营号和账号
     * @return HasOne
     */
    public function Account() : HasOne
    {
        return $this->HasOne(WeworkAccount::class, 'marketUserId', 'marketUserId');
    }
}